#encoding:utf-8

import json
import os

workSpace = './'
stdList = [
{
    'inFile' : '1.in',
    'outFile' : '1.out'
}]

class JudgeCore:
    @staticmethod
    def judge(path, className, stdIn):
        com = 'java -cp "%s" %s < "%s" 2>&1' % (path, className, stdIn)
        print(com)
        ret = os.popen(com).readlines()
        print(ret)
    @staticmethod
    def compile(path, className):
        com = 'javac -d "%s" "%s\\%s.java" 2>&1' % (path, path, className)
        ret = os.popen(com).readlines()
        print("编译%s\n编译输出：%s" % (path, ret))
        

userList = os.listdir('src')
#print(userList)
pathPrefix = os.getcwd()
pathList = []
for i in userList:
    pathList.append(pathPrefix + '\\src\\' + i)
#print(pathList)
'''
for i in pathList:
    JudgeCore.compile(i, 'SpiralMatrix')
'''
for i in pathList:
    JudgeCore.compile(i, 'SpiralMatrix')
    JudgeCore.judge(i, 'SpiralMatrix', pathPrefix + '\\problem\\SpiralMatrix\\data\\1.in')
with open('problem/SpiralMatrix/data/1.out', 'r') as stdOut:
    for i in stdOut.readlines():
        print(i.rstrip())